*--- Get the list of regions
use "${datadir}\HTB_main", replace
keep regionname
duplicates drop


*--- Get regional house prices
merge 1:m regionname using ///
	"${datadir}\local_price_appreciation", ///
	keepusing(index datem) gen(merge_region) keep(3)
keep if datem > ym(2014, 12) 


*--- Create two indices
gen group = .
replace group = 1 if regionname == "London"
replace group = 2 if regionname == "South East"
replace group = 3 if missing(group)
collapse index, by(datem group)

sum index if group == 1 & datem == ym(2015, 1), meanonly
gen rescale_index = index / r(mean) * 100 if group == 1

sum index if group == 2 & datem == ym(2015, 1), meanonly
replace rescale_index = index / r(mean) * 100 if group == 2

sum index if group == 3 & datem == ym(2015, 1), meanonly
replace rescale_index = index / r(mean) * 100 if group == 3


*--- Chart
format %tm datem
line rescale_index datem if group == 1, lwidth(medthick) || ///
	line rescale_index datem if group == 2, lwidth(medthick) lpattern(dash) || ///
	line rescale_index datem if group == 3, lwidth(thick) lpattern(dot) lcolor(black) ///
	${graphoption} xtitle("") ///
	ytitle("House price index (2010m1 = 100)") ///
	leg(order(1 "London" 2 "South-East" 3 "Rest of England") r(1))
graph export "${figuredir}\South-East_London_house_prices.pdf", ///
	as(pdf) replace

	
